package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductMapper extends BaseMapper<Product> {
    //如参数不为实体，多个参数会被包装为一个键值对map 类型是ParamMap
    @Insert(value = " insert into product(name) values (#{name})")
    void addProduct(@Param("name") String name);

    @Update(value = " update product set name = 'test' ")
    void updatePro1();

    @Update(value = " update product set name = #{product.name}, update_by = #{product.updateBy}, update_time = #{product.updateTime} where id = #{product.id} ")
    void updatePro2( Product product);

    @Select(value = " select * from product where create_by = #{name}")
    List<Product> selectPorduct(Product product,String name);

}
